import axiosInstance from '@/api/axiosInstance'
interface promotionListParams {
  name?: string
  is_all?:boolean
  // 其他查询条件...
}

// 获取推广计划列表
export const getPromotionList = async (params?: promotionListParams) => {
  return axiosInstance.get('/admin/promotion', { params })
}

// 获取推广计划详情
export const getPromotionDetail = async (id: number) => {
  return axiosInstance.get(`/admin/promotion/${id}`)
}
// 创建推广计划
export const createPromotion = async (data: any) => {
  return axiosInstance.post('/admin/promotion', data)
}

// 更新推广计划
export const updatePromotion = async (id: number, data: any) => {
  return axiosInstance.put(`/admin/promotion/${id}`, data)
}

// 删除推广计划
export const deletePromotion = async (id: number) => {
  return axiosInstance.delete(`/admin/promotion/${id}`)
}

//创建推广项目
export const createPromotionItem = async (id: number, data: any) => {
  return axiosInstance.post(`/admin/promotion/${id}/promotion-item`, data)
}

//更新推广项目
export const updatePromotionItem = async (id: number, itemId: number, data: any) => {
  return axiosInstance.put(`/admin/promotion/${id}/promotion-item/${itemId}`, data)
}

//删除推广项目
export const deletePromotionItem = async (id: number, itemId: number) => {
  return axiosInstance.delete(`/admin/promotion/${id}/promotion-item/${itemId}`)
}

// 获取推广码选项表
export const getPromotionCodes = async (type: number) => {
  return axiosInstance.get('/admin/promotion/codes', { params: { type } })
}
